package main

import (
    "net/http"
    "time"

    "github.com/prometheus/client_golang/prometheus"
    "github.com/prometheus/client_golang/prometheus/promhttp"
)

type myCollector struct {
    metric *prometheus.Desc
}

func (c *myCollector) Describe(ch chan<- *prometheus.Desc) {
    ch <- c.metric
}

func (c *myCollector) Collect(ch chan<- prometheus.Metric) {
    // your logic should be placed here

    t := time.Date(2009, time.November, 10, 23, 0, 0, 12345678, time.UTC)
    s := prometheus.NewMetricWithTimestamp(t, prometheus.MustNewConstMetric(c.metric, prometheus.CounterValue, 123))

    ch <- s
}

func main() {

    collector := &myCollector{
        metric: prometheus.NewDesc(
            "my_metric",
            "This is my metric with custom TS",
            nil,
            nil,
        ),
    }
    prometheus.MustRegister(collector)

    http.Handle("/metrics", promhttp.Handler())
    http.ListenAndServe(":8080", nil)
}

